import request from '@/utils/request'

// 首页轮播图
// export const swiper = () => request.get('/home/swiper')

// 租房小组
export const groups = () => request.get('/home/groups')

// 我的收藏
export const collect = () => request.get('/user/favorites')

// 我的出租
export const houses = () => request.get('/user/houses')

// 获取城市列表
export const city = () =>
  request.get('/area/city', {
    params: {
      level: 1
    }
  })

// 获取子级城市列表
export const cityarea = (code) =>
  request.get('/area', {
    params: {
      id: code
    }
  })

// 获取城市信息
export const areaIhfo = (name) =>
  request.get('/area/info', {
    params: {
      name: name
    }
  })

// 查询房源数据
export const areaMap = (code) =>
  request.get('/area/map', {
    params: {
      id: code
    }
  })

// 获取房屋查询条件
export const housesCond = (id) =>
  request.get('/houses/condition', {
    params: {
      id: id
    }
  })

// 获取发布房屋所需条件
export const housesParams = () => request.get('/houses/params')

// 获取具体房源信息
export const houseId = (code) => request.get(`/houses/${code}`)

// 热门城市
export const host = () => request.get('/area/hot')

// 查询房屋是否收藏
export const getFavorites = (code) => request.get('/user/favorites/' + code)
// 添加收藏
export const addFavorites = (code) => request.post('/user/favorites/' + code)
// 删除收藏
export const delFavorites = (code) => request.delete('/user/favorites/' + code)

// 小区关键字获取
export const community = (name, code) =>
  request.get('/area/community', {
    params: {
      name: name,
      id: code
    }
  })

// 发布房源
export const setHouses = (body) => request.post('/user/houses', body)

// 房屋图像上传
export const housesImg = data => request.post('/houses/image', data, {
  headers: {'Content-Type': 'multipart/form-data'}
})

// 根据条件查询房屋
export const ConditionHouses = (cityid, more) => request.get('/houses', {
  params: {
    cityid,
    more
  }
})